<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>进度条实例体验任务轮询</title>
    <style>
        #loading{
            height: 30px;
            background: chartreuse;
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>
<body>
    <div id = "loading"></div>
    <script>
        function handle(){
            let i = 0;
            (function run(){
                loading.style.width = i + '%';
                loading.innerHTML = i + '%';
                if(++i <= 100){
                    console.log(i);
                    setTimeout(run,50);
                }
            })()
        }
        handle();
    </script>
</body>
</html>